fix(atlas): honour a project pin only when its dedupe key matches#112
Merged
Conversation
resolveProjectId returned the local .openscience/project.json pin unconditionally, ignoring the dedupe_key that writeProjectPin had stored alongside it. When the pin is stale or belongs to a different identity — the remote was re-pointed to a fork, a .openscience/ dir was copied in, or the project was deleted — find-or-create returned the wrong/dead id and never created the correct graph, surfacing as 'the graph won't load / shows the wrong project / stays empty'. readProjectPin now returns the stored dedupe_key, and resolveProjectId trusts the pin only when pinMatchesKey() holds (no key = legacy pin, kept for back-compat; otherwise the key must equal the repo's freshly-computed key). A mismatched pin falls through to resolve-or-create, which overwrites it with the current key.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of the reasons "Atlas doesn't create/load the right graph."
Bug
resolveProjectIdhonoured the local.openscience/project.jsonpin unconditionally —readProjectPinreturned onlyproject_idand threw away thededupe_keythatwriteProjectPinstored next to it. So when the pin is stale or belongs to a different repo identity (the git remote was re-pointed to a fork, a.openscience/dir was copied into another repo, or the pinned project was deleted server-side), find-or-create returned the wrong/dead project id and never created the correct graph — which reads as "the graph won't load / shows the wrong project / stays empty."Fix
readProjectPinnow returns the storeddedupe_keytoo (ProjectPin).resolveProjectIdcomputes the repo's key first and trusts the pin only whenpinMatchesKey(pin, key)holds: a pin with no key is legacy and kept for back-compat; otherwise its key must equal the repo's freshly-computed key. A mismatched pin falls through to resolve-or-create, which rewrites the pin with the current key. The offline/fast path is preserved (the git calls that compute the key are local).Tests
pinMatchesKeycoverage added totest/server/atlas-bridge.test.ts: legacy pin (no key) trusted; matching key trusted; a key from a different repo identity rejected; a local-folder pin that no longer matches rejected. Existing dedupe-key / failure-classification / init tests unchanged (18 pass).